package ch.subgate.spritestudio.tools;

public class Converter {
	public static byte[] getByteArrayFromInteger(int i) {
		byte[] r = new byte[4];
		r[0] = (byte)((i & 0xff000000) >>> 24);
		r[1] = (byte)((i & 0x00ff0000) >> 16);
		r[2] = (byte)((i & 0x0000ff00) >> 8);
		r[3] = (byte)((i & 0x000000ff));
		return r;
	}
	
	public static int getIntegerFromByteArray(byte[] r) {
		int i = 0;
		i |= (0x000000ff & r[0]) << 24;
		i |= (0x000000ff & r[1]) << 16;
		i |= (0x000000ff & r[2]) << 8;
		i |= 0x000000ff & r[3];
		return i;
	}
}
